//variaveis globais
var map;
var arrayPontos = new Array();
var ckb_all_selected ;
var hr = new XMLHttpRequest();
var idUsuario = document.getElementById("idUsuario").value;
var geocoder;
var zoom = 10;
var exibir = 1;
var dataByDate = false;
//update
var time_interval = 'nt';
var timeOut;
var timeOutFlexi;
var mc;
var arrayCluster;

//Inicializacao do mapa
function initialize() {
	myLatlng = new google.maps.LatLng(-29.952417, -51.095350);
	geocoder = new google.maps.Geocoder();
	var mapOptions = {
			zoom: 10,
			center: myLatlng,
			mapTypeId: google.maps.MapTypeId.ROADMAP
	};

	map = new google.maps.Map(document.getElementById('map_canvas'),
			mapOptions);
	
	google.maps.event.addListener(map, 'zoom_changed', function() {
		   zoom = map.getZoom();
	});
	try {
		mc = new MarkerClusterer(map);
		mc.setGridSize(20);
		mc.setMaxZoom(10);
	} catch (e) {
		alert("new cluster:"+e)
	}	
}

function loadScript() {
	var script = document.createElement('script');
	script.type = 'text/javascript';
	script.src = 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=true&callback=initialize';
	document.body.appendChild(script);
}

function initVariables(){
	ckb_all_selected = document.getElementById('allPoints');
	updateFlexigrid();	
	arrayCluster = new Array();
}

window.onload = function () {
	loadScript();
	initVariables();
	getAllData();
	
}

//Fim da inicializacao do mapa

function setZoom(){
	
	for(var obj in document.getElementsByName("zoom")){
		
		if(document.getElementsByName("zoom")[obj].checked){
			
			zoom = document.getElementsByName("zoom")[obj].value;
			
			map.setZoom(parseInt(zoom, 10));
		}
	}
}


